<div class="content">
<h1>文章分类</h1>


<% form_for([:admin , @category] , :html=> {:class => 'form'}) do |f| %>
  <%= f.error_messages %>
  <p>
    名称：
    <%= f.text_field :name %>
    描述：
    <%= f.text_field :description %>
    <%= f.submit '添加' ,:class =>'button' %>
  </p>
<% end %>
        

<table class="table">
  <tr>
    <th>名称</th>
    <th>描述</th>
    <th>操作</th>
  </tr>
  
  <% @categories.each do |category| %>
    <tr>
      <td><%=h category.name %></td>
      <td><%=h category.description %></td>
      <td><%#= link_to 'Show',  admin_category_path(category) %>
        <%#= link_to '编辑', edit_admin_category_path(category) %>
        <%= link_to_function '修改', "$('category#{category.id}').toggle()" %>|
        <%= link_to '删除', admin_category_path(category), :confirm => 'Are you sure?', :method => :delete %></td>
    </tr>
  
  
    <% form_for([:admin ,category], :html=> {:class => 'form'}) do |f| %>
      
      <tr id="category<%=  category.id %>" style ='display:none' class = 'form'>
        <td>
          <%= f.text_field :name,:class =>'text_field' , :size => 3 %>
        </td>      
        <td>
          <%= f.text_field :description,:class =>'text_field'  , :size => 3 %>
        </td>
        <td>
          <%= f.submit '修改' ,:class =>'button' %>  
        </td>
      </tr>
    <% end %>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  <% end %>
</table>
</div>